﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Core.Primitives
{
    [Serializable]
    public struct IntSegment
    {
        private IntPosition m_pos1;
        public IntPosition Pos1
        {
            get { return m_pos1; }
            set { m_pos1 = value; }
        }

        private IntPosition m_pos2;
        public IntPosition Pos2
        {
            get { return m_pos2; }
            set { m_pos2 = value; }
        }

        public IntSegment(IntPosition p1, IntPosition p2)
        {
            m_pos1 = p1;
            m_pos2 = p2;
        }
        
        public override bool Equals(object obj)
        {
            if (obj is IntSegment)
            {
                IntSegment seg2 = (IntSegment)obj;

                return this.m_pos1.Equals(seg2.m_pos1) && this.m_pos2.Equals(seg2.m_pos2)
                    || this.m_pos1.Equals(seg2.m_pos2) && this.m_pos2.Equals(seg2.m_pos1);
            }

            return false;
        }
        public override int GetHashCode()
        {
            return m_pos1.GetHashCode() ^ m_pos2.GetHashCode();
        }
    }
}
